<!--商品条件检索-->
<div class="box m_10">
	<div class="cont">
		<!--品牌展示-->
		{set:$brandList = search_goods::$brandSearch}
		{if:$brandList}
		<dl class="sorting">
			<dt>品牌：</dt>
			<dd id='brand_dd'>
				<a class="nolimit current" href="{echo:search_goods::searchUrl('brand','')}">不限</a>
				{foreach:items = $brandList}
				<a href="{echo:search_goods::searchUrl('brand',$item['id'])}" id='brand_{$item['id']}'>{$item['name']}</a>
				{/foreach}
			</dd>
		</dl>
		{/if}
		<!--品牌展示-->

		<!--商品属性-->
		{foreach:items = search_goods::$attrSearch}
		<dl class="sorting">
			<dt>{$item['name']}：</dt>
			<dd id='attr_dd_{$item['id']}'>
				<a class="nolimit current" href="{echo:search_goods::searchUrl('attr['.$item["id"].']','')}">不限</a>
				{foreach:items=$item['value'] item=$attr}
				<a href="{echo:search_goods::searchUrl('attr['.$item["id"].']',$attr)}" id="attr_{$item['id']}_{echo:md5($attr)}">{$attr}</a>
				{/foreach}
			</dd>
		</dl>
		{/foreach}
		<!--商品属性-->

		<!--商品价格-->
		<dl class="sorting">
			<dt>价格：</dt>
			<dd id='price_dd'>
				<p class="f_r"><input type="text" class="mini" name="min_price" value="" /> 至 <input type="text" class="mini" name="max_price" value="" /> 元
				<label class="btn_gray_s"><input type="button" onclick="priceLink();" value="确定"></label></p>
				<a class="nolimit current" href="{echo:search_goods::searchUrl(array('min_price','max_price'),'')}">不限</a>
				{foreach:items=search_goods::$priceSearch}
				{set:$priceZone = explode('-',$item)}
				<a href="{echo:search_goods::searchUrl(array('min_price','max_price'),array($priceZone[0],$priceZone[1]))}" id="{$item}">{$item}</a>
				{/foreach}
			</dd>
		</dl>
		<!--商品价格-->
	</div>
</div>
<!--商品条件检索-->

<!--商品排序展示-->
<div class="display_title">
	<span class="l"></span>
	<span class="r"></span>
	<span class="f_l">排序：</span>
	<ul>
		{foreach:items=search_goods::getOrderType()}
		<li id="order_{$key}">
			<span class="l"></span><span class="r"></span>
			<a href="{echo:search_goods::searchUrl(array('order','by'),array($key,search_goods::getOrderBy($key)))}">{$item}<span id="by_{$key}">&nbsp;</span></a>
		</li>
		{/foreach}
	</ul>
	<span class="f_l">显示方式：</span>
	<a class="show_b" href="{echo:search_goods::searchUrl('show_type','win')}" title='橱窗展示' alt='橱窗展示'><span id="winButton"></span></a>
	<a class="show_s" href="{echo:search_goods::searchUrl('show_type','list')}" title='列表展示' alt='列表展示'><span id="listButton"></span></a>
</div>
<!--商品排序展示-->

<script type='text/javascript'>
//价格跳转
function priceLink()
{
	var minVal = $('input[name="min_price"]').val();
	var maxVal = $('input[name="max_price"]').val();
	if(isNaN(minVal) || isNaN(maxVal))
	{
		alert('价格填写不正确');
		return '';
	}
	var searchUrl = "{echo:search_goods::searchUrl(array('min_price','max_price'),array('__min_price__','__max_price__'))}";
	searchUrl     = searchUrl.replace("__min_price__",minVal).replace("__max_price__",maxVal);
	window.location.href = searchUrl;
}

//筛选条件按钮高亮
jQuery(function(){
	//品牌模块高亮和预填充
	{set:$brand = IFilter::act(IReq::get('brand'),'int');}
	{if:$brand}
	$('#brand_dd>*').removeClass('current');
	$('#brand_{$brand}').addClass('current');
	{/if}

	//属性模块高亮和预填充
	{set:$tempArray = IReq::get('attr')}
	{if:$tempArray}
		{set:$json = JSON::encode(array_map('md5',$tempArray))}
		var attrArray = {$json};
		for(val in attrArray)
		{
			if(attrArray[val])
			{
				$('#attr_dd_'+val+'>*').removeClass('current');
				$('#attr_'+val+'_'+attrArray[val]).addClass('current');
			}
		}
	{/if}

	//价格模块高亮和预填充
	{if:IReq::get('min_price') || IReq::get('max_price')}
	{set:$_minPrice = IFilter::act(IReq::get('min_price'),'float')}
	{set:$_maxPrice = IFilter::act(IReq::get('max_price'),'float')}
	{set:$priceId   = $_minPrice."-".$_maxPrice}
	$('#price_dd>*').removeClass('current');
	$('#{$priceId}').addClass('current');
	$('input[name="min_price"]').val("{$_minPrice}");
	$('input[name="max_price"]').val("{$_maxPrice}");
	{/if}

	//排序字段
	{set:$orderValue = IFilter::act(IReq::get('order'))}
	{if:$orderValue}
	$('#order_{$orderValue}').addClass('current');
	{/if}

	//顺序
	{set:$byValue = IReq::get('by')}
	{if:$byValue == "desc"}
	$('#by_{$orderValue}').addClass('desc');
	{else:}
	$('#by_{$orderValue}').addClass('asc');
	{/if}

	//显示方式
	{set:$showType = IReq::get('show_type');}
	{if:$showType == "win"}
	$('[name="goodsItems"]').attr({"class":"clearfix win"});
	$('[name="goodsImage"]').css({"width":200,"height":200});
	$('#winButton').addClass('current');
	{elseif:$showType == "list"}
	$('[name="goodsItems"]').attr({"class":"clearfix list"});
	$('[name="goodsImage"]').css({"width":115,"height":115});
	$('#listButton').addClass('current');
	{/if}
});
</script>